package core

import (
	"fmt"
)

// AlertProcessor 定义告警处理器接口
type AlertProcessor interface {
	ProcessAlert(alert interface{}) error
	GetName() string
	GetDescription() string
}

// Agent 定义agent的基本结构
type Agent struct {
	Name        string
	Description string
	Processor   AlertProcessor
	Enabled     bool
}

// NewAgent 创建新的agent实例
func NewAgent(name, description string, processor AlertProcessor) *Agent {
	return &Agent{
		Name:        name,
		Description: description,
		Processor:   processor,
		Enabled:     true,
	}
}

// Process 处理告警
func (a *Agent) Process(alert interface{}) error {
	if !a.Enabled {
		return fmt.Errorf("agent %s 已禁用", a.Name)
	}

	return a.Processor.ProcessAlert(alert)
}

// GetName 获取agent名称
func (a *Agent) GetName() string {
	return a.Name
}

// GetDescription 获取agent描述
func (a *Agent) GetDescription() string {
	return a.Description
}